<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Bizuser_model extends CI_Model {
    public function getBizUserById($userId) {
        $userId = intval($userId);
        $sql    = "SELECT * FROM `busiUser` WHERE id={$userId};";
        $query  = $this->db->query($sql);
        $bizUser = $query->row_array();
        if (!$bizUser || !isset($bizUser)) {
            $bizUser = array();
        }

        return $bizUser;
    }

    public function getBizUserByName($username) {
        $bizUser = array();
        $this->db->where('username', $username);
        $query = $this->db->get('busiUser');
        foreach ($query->result() as $row) {
            $bizUser = array(
                'id'       => $row->id,
                'nickname' => $row->nickname,
                'username' => $row->username,
                'password' => $row->password,
                'appId'    => $row->appId,
                'secret'   => $row->secret,
            );
        }

        return $bizUser;
    }
}
